#ifndef _VECTOR_H_
#define _VECTOR_H_

#include<iostream>
#include<algorithm>

using namespace std;

class Vector
{
 private:
  int sz;  //the size of the vector
  double* elem;
  int space;  //actual size of vector plus allocated space
              //allocated storage capacity
 public:
 Vector():sz{0},elem{nullptr},space{0}{}
 Vector(int n):sz{n},elem{new double[sz]},space{n}
  {
    for(int i=0;i<n;i++)
      elem[i]=0;
  }

 Vector(initializer_list<double>lst):sz{lst.size()},elem{new double[sz]},space{sz}
  {
    copy(lst.begin(),lst.end(),elem);
  }

  Vector(const Vector&);  //copy constructor
  Vector& operator=(const Vector&);
  double& operator[](int n);
  double operator[](int n) const;
  void reserve(int newalloc);
  void resize(int newsize);
  void push_back(double d);
  int size() const
  {
    return sz;
  }
  
  int capacity() const
  {
    return space;;
  }
  void print();
  
  ~Vector()
    {
      delete[] elem;
    }
};
#endif
